/*Calculate Score if Grade Entered in a Form (from 0 to 9) and Return A to F*/
#include<stdio.h>
#include<ctype.h>
main()
{
___char too_big(char score);/*if the function too big*/
___void goto_switch(char score);/*assining grade for scores 0-9*/
___char score;/*score or first character in the score*/
___char next1;/*second character in the score*/
___char next2;/*third character in the score*/
___clrscr();/*clear screen*/
___while(printf("\n\nEnter the score :"),(score=getchar()) != EOF)
___{
______if(isdigit(score))
_________if((next1=getchar()) && isdigit(next1) && next1=='0')
____________if((next2=getchar()) && score=='1' && next2=='\n')
_______________printf("The score is - A");/*grade if score is 10*/
____________else
____________{
_______________too_big(score);/*if number too big promt it*/
_______________while(next2!='\n')
__________________next2=getchar();/*if number has many char. it take them off*/
____________}
_________else
____________if(next1=='\n')
_______________goto_switch(score);/*if number is one digit goto assigning grade function*/
_________else
_________{
____________too_big(score);/*if number too big pormt it*/
____________while(next1!='\n')
_______________next1=getchar();/*if number has many char. it take them off*/
_________}
______else
______{
_________printf("The NUMBER is unrecogniseble.");/*promt about wrong character*/
_________printf("\nDo NOT use [a-z],[A-Z] or any punctuation.");
_________while(getchar()!='\n')
____________;/*if number has many characters it take extra characters off*/
______}
___}
}
/*function which assign grade for scores from 0 to 9*/
void goto_switch(char score)
{
___switch(score)
___{
______case '0':
______case '1':
______case '2':
______case '3':
______case '4':
______case '5':
_________printf("The grade is - F");
_________break;
______case '6':
_________printf("The grade is - D");
_________break;
______case '7':
_________printf("The grade is - C");
_________break;
______case '8':
_________printf("The grade is - B");
_________break;
______case '9':
_________printf("The grade is - A");
___}
}
/*function which promt big number and 'clear' score*/
char too_big(char score)
{
___printf("The score number too big.");
___score='\n';
___return score;
}